﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace HCQ2UI_Helper
{
    /// <summary>
    ///     
    /// </summary>
    public class DateJsonResult:JsonResult
    {
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            HttpResponseBase response = context.HttpContext.Response;

            response.ContentType = "application/json";
            if (this.ContentEncoding != null)
            {
                response.ContentEncoding = this.ContentEncoding;
            }

            if (this.Data != null)
            {
                JsonSerializerSettings setting = new JsonSerializerSettings();
                // 设置日期序列化的格式
                setting.DateFormatString = "yyyy-MM-dd";
                response.Write(JsonConvert.SerializeObject(Data, setting));
            }
        }
    }
}
